#ifndef IMPROVED_HPP
#define IMPROVED_HPP

#include <string>

#include "Algorithm.hpp"
#include "primeFunctions.hpp"

class Improved : virtual public Algorithm
{
private:
  yjy::Config *cf;
  float conf_last;
  const float dz_threshold = 128.0f;
  const double inpainting_radius = 3;
  int cadidator_num = 8;//note this data is injected by configuration file!

  void cvtColor(cv::Mat &origFloat, cv::Mat &origCIE);
  void cvtColor_inverse(cv::Mat &orig, cv::Mat &dst);

protected:
  virtual int calculateWS(float confidence, float data, int windowSize);
  virtual float calculatePriority(float data_term, float conf_term);
  virtual void visualize(cv::Mat &image_padded, cv::Mat &mask_padded, int windowSize);

  virtual void precedure(cv::Mat &image_padded, cv::Mat &mask_padded);
  virtual void findCandidatePatch(cv::Mat &image_padded, cv::Mat &mask_padded, int i, int j, int windowSize, std::vector<std::pair<float, cv::Point2i>> &candidators);
  virtual cv::Point2i findBestPatch(cv::Mat &image_padded, cv::Mat &mask_padded, int i, int j, int windowSize, std::vector<std::pair<float, cv::Point2i>> &candidators, cv::Point2f dxdy);
  virtual void afterIteration(cv::Mat &image_padded, cv::Mat &mask_padded, cv::Mat &confidence_padded, cv::Mat &data_paddeed, int i, int j);

public:
  Improved(yjy::Config *cf);
  ~Improved();
};

#endif